<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
	<head>
		<th:block th:include="include :: header('电影内容编辑')"/>
	</head>
	<body>
		<div class="layui-container">
			<form id="moiveForm" class="layui-form" style="margin-top: 20px;">
				<input type="hidden" name="id" th:value="${m.id}"/>
				<div class="layui-form-item">
					<label class="layui-form-label">电影名称</label>
					<div class="layui-input-block">
						<input name="movieName" th:value="${m.movieName}" class="layui-input" autocomplete="off" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">电影海报</label>
					<div class="layui-input-block">
						<input name="imgUrl" th:value="${m.imgUrl}" class="layui-input" autocomplete="off" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">下载地址</label>
					<div class="layui-input-block">
						<input name="href" th:value="${m.href}" class="layui-input" autocomplete="off" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">电影内容</label>
					<div class="layui-input-block">
						<textarea id="text" name="text" style="display: none;" th:text="${m.text}"></textarea>
					</div>
				</div>
				<div style="display: none">
					<a class="layui-btn" lay-submit="" id="submitBtn" lay-filter="submitBtn">确定保存</a>
				</div>
			</form>

		</div>
		<th:block th:include="include :: footer"/>
		<script>
			var $;
			layui.use(['form','layedit','jquery'],function(){
				var form = layui.form,layedit = layui.layedit;
				$ = layui.jquery;
				var index = layedit.build('text');//建立富文本编辑器

				//监听隐藏的按钮事件
				form.on('submit(submitBtn)',function (data) {
					var data = data.field;
					//获取富文本内容
					var text = layedit.getContent(index);
					data.text = text;
					console.log(data);
					saveOrUpdate("/mc/saveOrUpdate",'movieTableId',data,$);
				});

			});

			function submitClick(){
				$('#submitBtn').click();
			}
		</script>
	</body>
</html>
